﻿#pragma once
#include "Scene.h"
#include "Terrain.h"
#include "GuiMain.h"
#include "GameObjectList.h"
#include "PlayerObject.h"
#include "PlayerMe.h"
#include "MuNetConnect.h"

class Monster;

class SceneMain :
    public Scene,
    protected MuNetConnect::Listener
{
public:
	SceneMain();
	virtual ~SceneMain();

	CREATE_FUNC(SceneMain)

	virtual bool Init();
	virtual void window_size_callback(int width, int height) override;
	virtual void mouse_button_callback(int button, int action, int mods) override;
	virtual void cursor_position_callback(double xpos, double ypos) override;
	virtual void Update() override;

	Camera m_camera;
	Viewport m_viewport1;

private:
	void ObjectPick();
	GameObject *GetGameObjectFromId(int id);

	void SetMaxLife(int num);
	void SetCurrLife(int num);
	void SetMaxMana(int num);
	void SetCurrMana(int num);

	void cb_FocusObj_monster(Monster *monster, bool focus);
	void cb_SelectObj_monster(Monster *monster, bool select);

	bool m_lbtnDown;

	Terrain *m_terrain;
	GuiMain m_guiMain;
	GameObjectList m_gameObjList1;
	PlayerMe m_playerMe;
	BoundBoxObject *m_currFocusObj;
	BoundBoxObject *m_currSelectObj;

    // 继承 MuNetConnect::Listener
    virtual void on_cs_close() override;
    virtual void on_gs_close() override;
    virtual void on_gs_moveNotice(MuPack::MoveNotice* moveNotice) override;
    virtual void on_gs_placePlayer(MuPack::PlacePlayer* placePlayer) override;
    virtual void on_gs_placeMonster(MuPack::PlaceMonster* placeMonster) override;
    virtual void on_gs_removeTarget(MuPack::RemoveTarget* removeTarget) override;
    virtual void on_gs_changeDir(MuPack::ChangeDir *changeDir) override;
    virtual void on_gs_setCurrLife(size_t currLife) override;
    virtual void on_gs_setCurrMana(size_t currMana) override;
    virtual void on_gs_characterInfo(MuPack::CharacterInfo* charInfo) override;
};

